package chloroform

import javax.validation.constraints.{Size, Min}
import scaladuct.hint.Help
import java.lang.String
import scaladuct._
import lists.ListsSource
import lists.scala.{ListForProperty, ListsManager}

/**
 * <p>
 * Created by IntelliJ IDEA.
 * User: zslajchrt
 * Date: Dec 12, 2010
 * Time: 10:20:45 PM
 */

class TwoReferencesStarter extends Starter[String] with ListsSource {

  def newInstance(): String = phaseOne(1, "xyz", true, NiceEnum1.NiceValue1, "", "")

  @Help("phaseOne")
  def phaseOne(@Min(100) @Help a: Int,
               @Size(min = 3, max = 10) b: String,
               c: Boolean,
               d: NiceEnum1,
               @Ref(name = "ref1") refString1: String,
               @Ref(name = "ref2") refString2: String): String = {
    println("RefPhaseOne")
    phaseTwo(a, refString1, refString2, true)
  }

  @Help
  def phaseTwo(a: Int, refString1: String, refString2: String, @First reverse: Boolean): String = {
    println("RefPhaseTwo")
    if (reverse)
      "!" + refString2 + refString1 + a
    else
      "" + a + refString1 + refString2 + "!"
  }


  def destroy(instance: String) = null

  def listsForPhase(phase: String) = phase match  {
    case "phaseOne" => {
      Some(new ListsManager {
        def scalaListForProperty(property: Property[AnyRef]) = property.name match {
          case "parameter1" => {
            Some(new ListForProperty(property, List("Value1", "Value2", "Value3"), true, true))
          }
          case _ => None
        }
      })
    }
    case _ => None
  }
}